$(...)
'?$(document).ready(function() { // What is 'document'? What is '$(...)'? What is 'ready(...)'? What is 'function() {...}'? $(selector).action(); // Do this action over selected objects });
$(document).ready(function() { $(selector).event(function() { // When this event is triggered $(selector).action(); // do this action over selected objects $(this).action(); // What is 'this'? The current HTML DOM element or $(selector)? }); }); // or $(function() { // Nothig different from the above example. Can you imagin how $ works? $(selector).on(eventname, function() { $(selector).action(); $(this).action(); // What is 'this'? The current HTML DOM element or $(selector)? }); });
$('p')
$('#test')
, $('p#test')
$('.testclass')
, $('p.testclass')
$(this)
$("div[data-target]")
, $("input[name='property']:checked")
data()
", each()
", "get()
", "index()
", "toArray()
" in jQuery Miscellaneous Methods.alert($(this).text());
? alert($(this).innerHTML);
?
alert($('dev').length);
on()
in the last example?<ol id='testNestedOl'> <li>COMP 2680</li> <li>COMP 3540</li> <li>COMP 4620</li> </ol> <script> $('???').css('list-style-type', 'none'); // To remove ordering numbers $('#testNestedOl > ???').???('display', '???'); // In order to make <li> be displayed in the same line $('#testNestedOl > li').???(function() { // For each of them $(this).???('2.' + (Number($(this).???()) + 1) + ' '); // Before each <li>, using .before() $(this).html($(this).html() + '<br>'); // Include a line break at the end of the list. }); /* or $('#testNestedOl > li').???(function() { // For each of them $(this).???('2.' + (Number($(this).???()) + 1) + ' '); // Before each <li>, using .prepend() }); */ $('#testNestedOl > li:???').hover(function() { // even or odd $(this).css('background-color', 'Grey'); }, function() { $(this).css('background-color', 'transparent'); // or 'inherit'? }); </script>